Skip to content

Conversation

@Daniel-Santiago-Acosta-1013

What

  • Avoid hard-wrapping URL lines in history in TUI/TUI2.
  • Fix wrapped row counts for long lines (soft wrap) in history rendering.
  • Add tests for long URL wrapping.

Why

How

  • Skip word wrapping for lines containing URLs in history insertion.
  • Use row count based on line width and viewport width.
  • Add unit tests in TUI and TUI2.

Testing

  • just fmt
  • just fix -p codex-tui
  • just fix -p codex-tui2
  • cargo test -p codex-tui
  • cargo test -p codex-tui2

@github-actions
Copy link
Contributor

github-actions bot commented Jan 5, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@Daniel-Santiago-Acosta-1013
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

@etraut-openai
Copy link
Collaborator

@codex review

@chatgpt-codex-connector
Copy link
Contributor

Codex Review: Didn't find any major issues. More of your lovely PRs please.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@joshka-oai joshka-oai self-assigned this Jan 8, 2026
Copy link
Collaborator

@joshka-oai joshka-oai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can go a bit deeper here and make an intelligent wrap before URLs a thing - i.e. when they'd wrap in the middle of the URL, force a wrap before. We will still need to character wrap when they're too long for the terminal regardless (and need tests for that scenario), but this would at least cut down the problems of not quite enough space to wrap. In effect, we want to treat the url as a word / non-breakable token somehow. This should probably also be in the wrapping code, not the insert_history code btw.

Strong support for fixing this. So please continue on this when you can.

joshka-oai

This comment was marked as duplicate.

@etraut-openai etraut-openai added the needs-response Additional information is requested label Jan 8, 2026
@etraut-openai etraut-openai added needs-response Additional information is requested and removed needs-response Additional information is requested labels Jan 9, 2026
@etraut-openai etraut-openai removed the needs-response Additional information is requested label Jan 12, 2026
Copy link
Collaborator

@joshka-oai joshka-oai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I tried this out in both tui and tui2, I asked codex to produce a url that was long enough to wrap. I saw the wrapping seemed like it still happened mid url. It would probably be good to add some tests that use insta around these things (as these tend to be visual rather than programmatic).

tui
Image

tui2
Image

use ratatui::text::Line;
use ratatui::text::Span;

fn wrap_history_lines<'a>(lines: &'a [Line<'a>], width: u16) -> Vec<Line<'a>> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs a doc comment clarifying intent

use ratatui::text::Line;
use ratatui::text::Span;

fn wrap_history_lines<'a>(lines: &'a [Line<'a>], width: u16) -> Vec<Line<'a>> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit (subjective preference): I'd prefer to see this below where it's called as it makes the code easier generally to read top-to-bottom outside-in.

Comment on lines +33 to +37
} else {
base_opts
.clone()
.initial_indent(base_opts.subsequent_indent.clone())
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a bit odd. I'm not sure I understand why we need to do this rather than relying on initial indent directly here.

let width = width.max(1) as usize;
let mut rows = 0usize;
for line in lines {
let line_width = line.width().max(1);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love the width() call here (it's likely not a significant perf hit, but becomes one easily with large enough history which can cause rendering slowdowns - more-so in tui2 than tui.

Not a big deal, but if there's a simple fix to avoid this (like storing the line + width computed once here) that would be great.

Comment on lines +50 to +53
for line in lines {
let line_width = line.width().max(1);
rows = rows.saturating_add(line_width.div_ceil(width));
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can probably be more written more succinctly / obviously with map + sum

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add covering tests (make codex produce these so that all the edge cases / behavior are properly tested).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants